import type { PageParams, PageResult } from '@/types/global'
import type { BannerItem, CategoryItem, GuessItem, HotItem, SanCodeItem } from '@/types/home'
import { http } from '@/utils/http'

/**
 * 首页-广告区域-小程序
 * @param distributionSite 广告区域展示位置（投放位置 投放位置，1为首页，2为分类商品页） 默认是1
 */
export const getHomeBannerAPI = (data = {}) => {
  return http<BannerItem[]>({
    method: 'POST',
    url: '/app/home/cycle',
    data,
  })
}

/**
 * 首页-前台分类-小程序
 */
export const getHomeCategoryAPI = () => {
  return http<CategoryItem[]>({
    method: 'GET',
    url: '/home/category/mutli',
  })
}

/**
 * 首页-热门推荐-小程序
 */
export const getHomeHotAPI = () => {
  return http<HotItem[]>({
    method: 'GET',
    url: '/home/hot/mutli',
  })
}

/**
 * 新闻列表-小程序
 */
export const getHomeGoodsGuessLikeAPI = (data?: PageParams) => {
  return http<PageResult<GuessItem>>({
    method: 'POST',
    url: '/app/home/cycle',
    data,
  })
}

/**
 * 扫码
 */

export const sanCodeChargingAPI = (data: { gunId: string }) => {
  return http<PageResult<SanCodeItem>>({
    method: 'POST',
    url: '/app/charge/scan',
    data,
  })
}
